package cn.structure.edp;

import cn.structure.ClassEntity;
import cn.structure.MethodEntity;

import java.util.Objects;

public class RevertMethod extends EdpEntity {
    private ClassEntity originalBehavior;
    private MethodEntity operation;
    private MethodEntity operation2;
    private ClassEntity revertedBehavior;

    public RevertMethod(ClassEntity originalBehavior, MethodEntity operation, MethodEntity operation2, ClassEntity revertedBehavior) {
        super();
        this.originalBehavior = originalBehavior;
        this.operation = operation;
        this.operation2 = operation2;
        this.revertedBehavior = revertedBehavior;
    }

    public enum Role {
        originalBehavior, operation, operation2, revertedBehavior
    }

    public ClassEntity getOriginalBehavior() {
        return originalBehavior;
    }

    public void setOriginalBehavior(ClassEntity originalBehavior) {
        this.originalBehavior = originalBehavior;
    }

    public MethodEntity getOperation() {
        return operation;
    }

    public void setOperation(MethodEntity operation) {
        this.operation = operation;
    }

    public MethodEntity getOperation2() {
        return operation2;
    }

    public void setOperation2(MethodEntity operation2) {
        this.operation2 = operation2;
    }

    public ClassEntity getRevertedBehavior() {
        return revertedBehavior;
    }

    public void setRevertedBehavior(ClassEntity revertedBehavior) {
        this.revertedBehavior = revertedBehavior;
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder("RevertMethod{\n\t");
        sb.append(super.toString());
        sb.append("\n\t\"originalBehavior\":")
                .append(originalBehavior);
        sb.append(",\n\t\"operation\":")
                .append(operation);
        sb.append(",\n\t\"operation2\":")
                .append(operation2);
        sb.append(",\n\t\"revertedBehavior\":")
                .append(revertedBehavior);
        sb.append("\n}");
        return sb.toString();
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        if (!super.equals(o)) return false;
        RevertMethod that = (RevertMethod) o;
        return Objects.equals(originalBehavior, that.originalBehavior) &&
                Objects.equals(operation, that.operation) &&
                Objects.equals(operation2, that.operation2) &&
                Objects.equals(revertedBehavior, that.revertedBehavior);
    }

    @Override
    public int hashCode() {
        return Objects.hash(super.hashCode(), originalBehavior, operation, operation2, revertedBehavior);
    }
}
